<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/common.css"/>
	</head>

	<body>
		<div class="mui-content">
			<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media">
					<a id="link_myface" href="javascript:;">
						<span class="mui-pull-right mui-icon mui-icon-arrowright icon-arrowright head-image-icon-arrrowright"></span>
						<img id="img_myface" class="mui-media-object mui-pull-right" src="image/helmos.png">
						<div class="mui-media-body list-item-title head-portrait-title">
							头像
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a id="link_nickname" href="javascript:;">
						<span class="mui-pull-right mui-icon mui-icon-arrowright icon-arrowright"></span>
						<span id="span_nickname" class="mui-pull-right list-item-content">糖果墙</span>
						<div class="mui-media-body list-item-title">
							昵称
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a href="javascript:;">
						<span id="span_username" class="mui-pull-right list-item-content">candywall</span>
						<div class="mui-media-body list-item-title">
						    账号
						</div>
					</a>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a id="link_qrcode" href="javascript:;">
						<span class="mui-pull-right mui-icon mui-icon-arrowright icon-arrowright"></span>
						<img id="qrcode-small-icon" class="mui-media-object mui-pull-right" src="image/qrcode.png">
						<div class="mui-media-body list-item-title">
						    我的二维码
						</div>
					</a>
				</li>
			</ul>
			<br />
			<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media">
					<a id="link_logout" href="javascript:;">
						<div class="mui-media-body list-item-title list-item-logout">
						    退出登录
						</div>
					</a>
				</li>	
			</ul>
		</div>
		<script src="js/mui.js"></script>
		<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init();
			
			mui.plusReady(function() {
				// 获取当前WebView刷新用户信息
				var curWebView = plus.webview.currentWebview();
				curWebView.addEventListener("show", function() {
					refreshUserinfo();
				});
				
				// 页面跳转：我的头像
				document.getElementById("link_myface").addEventListener("tap", function() {
					mui.openWindow("myface.html", "myface.html");
				});
				
				// 页面跳转：修改昵称
				document.getElementById("link_nickname").addEventListener("tap", function() {
					mui.openWindow("nickname.html", "nickname.html");
				});
				
				// 页面跳转：我的二维码
				document.getElementById("link_qrcode").addEventListener("tap", function() {
					mui.openWindow("myQRCode.html", "myQRCode.html");
				});
				
				// 退出登录
				document.getElementById("link_logout").addEventListener('tap', function() {
					app.logout();
					mui.openWindow({
						url: "login.html",
						id: "login.html",
						createNew: true
					});
				});
				
				// 自定义事件，刷新 我 页面的中的个人头像
				window.addEventListener("refresh", function() {
					refreshUserinfo();
				});
			});
			
			function refreshUserinfo() {
				var userinfo = app.getGlobalUserInfo();
				if(userinfo != null) {
					// 如果没有设置头像，就用默认头像
					var face_img_src = app.default_face_img_src;
					if(app.isNotNull(userinfo.faceImage)) {
						face_img_src = userinfo.faceImage;
					}
					document.getElementById("img_myface").src = app.imgServerUrl + face_img_src;
					document.getElementById("span_nickname").innerHTML = userinfo.nickname;
					document.getElementById("span_username").innerHTML = userinfo.username;
				}
			}
		</script>
	</body>

</html>
